package com.zw.mizhe.presenter;

import com.zw.mizhe.api.BaseSubscriber;
import com.zw.mizhe.api.ExceptionHandle;
import com.zw.mizhe.bean.temai.HomeEntity;
import com.zw.mizhe.common.base.mvp.BasePresenter;
import com.zw.mizhe.model.IHomeModel;
import com.zw.mizhe.model.impl.HomeModelImpl;
import com.zw.mizhe.view.impl.HomeFragmentView;

/**
 * Created by zhangwei on 16/10/22.
 */

public class HomePresenter extends BasePresenter<HomeFragmentView> {
    private IHomeModel model;

    public HomePresenter() {
        model = new HomeModelImpl();
    }

    public void getData(int page, String type, String path) {
        model.getHomeData(page, type, path, new BaseSubscriber<HomeEntity>() {
            @Override
            public void onError(ExceptionHandle.ResponeThrowable e) {
                getView().onFail(e);
            }

            @Override
            public void onSuccess(HomeEntity homeEntity) {
                getView().onSuccess(homeEntity);
            }

            @Override
            public void onFinish() {
                getView().onFinish();
            }
        });
    }

}
